/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "multa_prestamo", catalog = "mydb", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"multap_id_pre"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MultaPrestamo.findAll", query = "SELECT m FROM MultaPrestamo m"),
    @NamedQuery(name = "MultaPrestamo.findByMultapId", query = "SELECT m FROM MultaPrestamo m WHERE m.multapId = :multapId")})
public class MultaPrestamo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "multap_id")
    private Integer multapId;
    @JoinColumn(name = "multap_id_tp", referencedColumnName = "tp_id", nullable = false)
    @ManyToOne(optional = false)
    private PrestamoTipo multapIdTp;
    @JoinColumn(name = "multap_id_pre", referencedColumnName = "prest_id", nullable = false)
    @OneToOne(optional = false)
    private Prestamo multapIdPre;
    @JoinColumn(name = "multap_id_multa", referencedColumnName = "multa_id", nullable = false)
    @ManyToOne(optional = false)
    private Multa multapIdMulta;

    public MultaPrestamo() {
    }

    public MultaPrestamo(Integer multapId) {
        this.multapId = multapId;
    }

    public Integer getMultapId() {
        return multapId;
    }

    public void setMultapId(Integer multapId) {
        this.multapId = multapId;
    }

    public PrestamoTipo getMultapIdTp() {
        return multapIdTp;
    }

    public void setMultapIdTp(PrestamoTipo multapIdTp) {
        this.multapIdTp = multapIdTp;
    }

    public Prestamo getMultapIdPre() {
        return multapIdPre;
    }

    public void setMultapIdPre(Prestamo multapIdPre) {
        this.multapIdPre = multapIdPre;
    }

    public Multa getMultapIdMulta() {
        return multapIdMulta;
    }

    public void setMultapIdMulta(Multa multapIdMulta) {
        this.multapIdMulta = multapIdMulta;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (multapId != null ? multapId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MultaPrestamo)) {
            return false;
        }
        MultaPrestamo other = (MultaPrestamo) object;
        if ((this.multapId == null && other.multapId != null) || (this.multapId != null && !this.multapId.equals(other.multapId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return multapIdPre.getPrestId() + " [" + multapIdMulta.getMultaMonto() + "]";
    }
    
}
